<template>

    <h2>等级权益添加</h2>
    
    
    <table class="table table-bordered">
    <tr>
        <th>会员等级名称</th>
        <th>
            <input type="text" v-model="info.Rank_Name" >
        </th>
    </tr>
    
    <tr>
        <th>会员等级状态</th>
        <th> <input type="radio"  value="true" v-model="info.Rank_State">启用
            <input type="radio"  value="false" v-model="info.Rank_State">禁用
        </th>
    </tr>
    
    
    <tr>
        <th>最大成长值</th>
        <th>
            <input type="text"  v-model="info.Rank_MaxPoint">
        </th>
    </tr>
    
    
    <tr>
        <th>最小成长值</th>
        <th>
            <input type="text" v-model="info.Rank_MinPoint">
        </th>
    </tr>
    
    <tr>
        <th></th>
        <th>
            <input type="button" value="添加会员等级" @click="AddRank" class="btn btn-success">
        </th>
    </tr>
    
    </table>
    
    
    </template>
    
    <script setup lang="ts">
    

        import{useRoute,useRouter}from 'vue-router'
        import {onMounted, ref} from 'vue'
    
        onMounted(()=>{

            FanTianRank();
        })
    
        import axios from 'axios';
    
        const route=useRoute();
        const router=useRouter();
        const info =ref({
         Rank_Id: route.params.Rid,
      Rank_Name:"",
      Rank_State: true,
      Rank_MaxPoint: 0,
      Rank_MinPoint: 0
    
        })

            const AddRank =()=>{
    
                    axios .put('https://localhost:7035/api/Rank/UpRank',info.value)
    
                    .then(res=>{
    
                            if(res.data>0){
    
                                alert('修改成功')

                                router.push("/Rank_Show")
                            }
                            else 
                            {
                                alert('修改失败')
                            }
    
                    })
    
                    .catch(x=>{
    
                        console.log(x);
                    })
    
    
            }
    
    
    
    
    
                const FanTianRank=()=>{

                            axios('https://localhost:7035/api/Rank/FanTianRank?id='+route.params.Rid).then(res=>{

                         
                             info. value.Rank_Name=res.data.Rank_Name,
                             info. value.Rank_State= res.data.Rank_State,
                             info. value. Rank_MaxPoint= res.data.Rank_MaxPoint,
                             info. value.Rank_MinPoint=res.data.Rank_MinPoint

                            }).catch(x=>{

                                console.log(x);
                            })


                }


    </script>